package com.kede.api.level.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kede.api.level.domain.SyLevel;
import com.kede.api.level.mapper.SyLevelMapper;
import com.kede.api.level.service.ISyLevelService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 乔包包
 * @PackageName server-parent-master
 * @Package com.kede.api.level.service.impl
 * @Date 2024/2/3 11:16
 * @Version 1.0
 */
@Service
public class SyLevelServiceImpl extends ServiceImpl<SyLevelMapper, SyLevel> implements ISyLevelService {

    @Override
    public SyLevel getLowLevel() {
        LambdaQueryWrapper<SyLevel> wp = new LambdaQueryWrapper<SyLevel>();
        wp.eq(SyLevel::getStatus, 1);
        wp.orderByAsc(SyLevel::getLevel);
        wp.last("LIMIT 1");
        return this.getOne(wp);
    }

    @Override
    public SyLevel getHighLevel() {
        LambdaQueryWrapper<SyLevel> wp = new LambdaQueryWrapper<SyLevel>();
        wp.eq(SyLevel::getStatus, 1);
        wp.orderByDesc(SyLevel::getLevel);
        wp.last("LIMIT 1");
        return this.getOne(wp);
    }

    @Override
    public SyLevel getById(Integer id) {
        LambdaQueryWrapper<SyLevel> wp = new LambdaQueryWrapper<SyLevel>();
        wp.eq(SyLevel::getId,id);
        return this.getOne(wp);
    }
}
